package framework.service.impl;

import framework.bo.SysRoleMenu;
import framework.dao.ISysRoleMenuDao;
import framework.service.SysRoleMenuService;
import framework.util.layui._LayuiUtil;
import framework.util.queryFilter.service.impl.IBaseServiceImpl;
import javax.annotation.Resource;

import framework.util.queryFilter.service.impl.QueryFilter;
import framework.util.queryFilter.vo.Where;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service("SysRoleMenuService")
public class SysRoleMenuServiceImpl extends IBaseServiceImpl<SysRoleMenu, Integer> implements SysRoleMenuService {

    @Resource
    private ISysRoleMenuDao dao;


    @Override
    public void grantMenu(String rolelid, List<SysRoleMenu> list) {
        QueryFilter filter = new QueryFilter(_LayuiUtil.FIRST_PAGE, Integer.MAX_VALUE);
        filter.where(SysRoleMenu.ROLE_LID, Where.eq, rolelid);
        this.removeByQueryFilter(filter);

        if(!CollectionUtils.isEmpty(list)){
            this.addBatch(list);
        }
    }
}

